let store_openid_key ="storeopenidkey"
class Store_Openid {
	
	getMyopenid() {
		let val = uni.getStorageSync(store_openid_key)
		if(val){
			let nowTimes = new Date().getTime()
			if(nowTimes - val.expiretime>0){
				//过期
				return ''
			}
			return val.openid
		}
		return ''
	}
    setMyopenid(openid) {
		let dic = {
			openid:openid,
			expiretime:(new Date().getTime())+24*3600000 //过期时间为3天
		}
		uni.setStorageSync(store_openid_key,dic)
	}
}

export default {
	setStorage(p) {
		let that = this;
		that.removeStorage(p.key, () => {
			uni.setStorage({
				key: p.key,
				data: p.jsonstr,
				success: function(res) {
					if (p.success) p.success();
				},
				fail() {
					if (p.fail) p.fail();
				}
			});
		});
	},
	getStorage(p) {
		let that = this;
		uni.getStorage({
			key: p.key,
			success: function(res) {
				if (p.success) p.success(res.data);
			},
			fail() {
				if (p.fail) p.fail();
			}
		});
	},
	getStorageSync(p) {
		let that = this;
		let val = uni.getStorageSync(p.key)
		return val;
	},
	removeStorage(key, call) {
		uni.removeStorage({
			key: key,
			success: function() {
				if (call) call();
			}
		});
	},
	clearStorage() {

	},
	storeOpen:new Store_Openid()
}


